<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSON</title>
    <!--
        JSON是特殊格式的字符串
        用于记录并传输数据
    -->
</head>
<body>
<script>
    //json串
    var JSONStr = '{"name":"杨树林","age":11,"address":"河北张家口"}';//外单引号,内双引号

    //串转对象
    let JSONObj = JSON.parse(JSONStr);
    console.log(JSONObj);
    //Object
    //address:"河北张家口"
    //age:11
    //name:"杨树林"

    console.log(JSONObj.name);//杨树林

    //对象转串
    var JSONStr2 = JSON.stringify(JSONObj);
    console.log(JSONStr2);//{"name":"杨树林","age":11,"address":"河北张家口"}
    console.log(typeof (JSONStr2));//string
</script>
</body>
</html>